package org.ztr.yanai.blog.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Author: ZhaoTR
 * @Date: Created in 2025/11/22 10:00
 * @Description: 用户状态枚举
 * @Version: 1.0
 */
// 用户状态枚举
@Getter
@AllArgsConstructor
public enum UserStatusEnum {
    ACTIVE(1, "激活"),
    DISABLED(0, "禁用"),
    ENABLED(1, "启用");

    @EnumValue
    private final int code;
    
    private final String desc;

    // 根据 code 获取枚举实例
    public static UserStatusEnum fromCode(int code) {
        for (UserStatusEnum status : values()) {
            if (status.code == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("Invalid code: " + code);
    }
}